<template>
  <div class="search_">
    <nav-bar class="navBar">
      <router-link to="/" slot="left"> <div class="back"></div></router-link>
      <div slot="center" class="center">
        <search-view></search-view>
      </div>
      <div slot="right" class="right">
        <button>搜索</button>
      </div>
    </nav-bar>
    <div class="main">
      <div class="header">
        <span>热门搜索</span>
        <button @click="isActive()">{{ this.btn }}</button>
      </div>
      <div class="search_history">
        <div class="ul" v-if="isShow">
          <ul>
            <li v-for="item in name" :key="item">
              {{ item }}
            </li>
          </ul>
        </div>
        <div class="hidden" v-else>
          <span>已隐藏搜索发现</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import navBar from "../components/navBar.vue";
import searchView from "../components/search.vue";
export default {
  data() {
    return {
      name: [
        "金士顿内存",
        "华为手环",
        "直饮水龙头",
        "紫砂花盆",
        "微波炉",
        "空气炸锅",
        "橄榄调和油",
        "高清线hdmi",
        "演唱会望远镜",
        "珊瑚绒床垫",
      ],
      isShow: true,
      btn: "隐藏",
    };
  },
  components: {
    searchView,
    navBar,
  },
  methods: {
    isActive() {
      this.isShow = !this.isShow;
      if (this.isShow == true) {
        this.btn = "隐藏";
      } else {
        this.btn = "显示";
      }
    },
  },
};
</script>
<style>
.search_ .navBar {
  display: flex;
  flex-flow: row;
  justify-content: center;
  border-bottom: 1px solid rgb(229, 229, 229);
  height: 42px;
}
.search_ .navBar .back {
  position: relative;
  float: left;
  margin-top: 15px;
  margin-right: 15px;
  border: none;
  border-top: 2px solid;
  border-left: 2px solid;
  width: 10px;
  height: 10px;
  transform: rotate(-45deg);
}
.search_ .navBar .center {
  position: relative;
  margin-left: 20px;
  margin-top: 5px;
}
.search_ .navBar .right button {
  color: white;
  background-color: rgb(233, 59, 61);
  border: none;
  width: 40px;
  height: 30px;
  border-radius: 5px;
  margin-top: 5px;
  margin-left: 5px;
}
.search_ .main {
  position: relative;
}
.search_ .main .header {
  height: 40px;
}
.search_ .main .header span {
  position: relative;
  float: left;
  margin-left: 15px;
  margin-top: 15px;
}
.search_ .main .header button {
  position: relative;
  float: right;
  margin-top: 15px;
  margin-right: 20px;
  border: none;
  background-color: white;
  color: rgb(153, 153, 153);
}
.search_ .main .search_history .ul li {
  display: inline-flex;
  font-size: 12px;
  background-color: rgb(240, 242, 245);
  flex-wrap: wrap;
  flex-flow: row;
  margin-left: 10px;
  border-radius: 5px;
  width: auto;
  line-height: 25px;
  padding-left: 5px;
  padding-right: 5px;
  margin-top: 10px;
  color: #686868;
}
.search_ .main .search_history .hidden {
  position: relative;
  margin-top: 50px;
  margin-left: 110px;
  font-size: 13px;
  color: #686868;
}
</style>